import type { CaseType } from "../task/index.d";
import type { TestResultItem, TestLogsItem, SkyTestResult, GeneratorInfo, GroundDirectionAccuracies, Environment, DialogParams, TestStatus } from "./index.d";
import type { PagingParames, PagingResponse } from "../index.d";
import type { nodeItem } from "mctp-platform/src/components/index";

const testModuleId = "TestForm";
import { createCommand } from '../../commandHelper';

/**
 * @description: 打开任务
 */
export const openTask = createCommand<never, never>(testModuleId, { command: "OpenTask" });

/**
 * @description: 关闭任务
 */
export const closeTask = createCommand<{ taskId: string }, never>(testModuleId, { command: "CloseTask" });

/**
 * @description: 开始测试
 */
export const startTest = createCommand<{ selectCaseIds: (string | number)[] }, never>(testModuleId, { command: "StartTest" });

/**
 * @description: 暂停测试
 */
export const pauseTest = createCommand<{}, never>(testModuleId, { command: "PauseTest" });

/**
 * @description: 继续测试
 */
export const resumeTest = createCommand<{}, never>(testModuleId, { command: "ResumeTest" });

/**
 * @description: 停止测试
 */
export const stopTest = createCommand<{}, never>(testModuleId, { command: "StopTest" });

/**
 * @description: 获取测试用例树
 */
export const getTestCaseTrees = createCommand<{ keyword: string | null }, CaseType>(testModuleId, { command: "GetTestCaseTrees" });

/**
 * @description: 获取测试用例配置
 */
export const getTestCaseConfig = createCommand<{ caseId: string }, never>(testModuleId, { command: "GetTestCaseConfig" });

/**
 * @description: 获取测试例结果
 */
export const getTestCaseReults = createCommand<{ testCaseId: string }, TestResultItem[]>(testModuleId, { command: "GetTestCaseReults" });

/**
 * @description: 获取测试用例日志
 */
export const getTestLogsByPage = createCommand<PagingParames, PagingResponse<TestLogsItem[]>>(testModuleId, { command: "GetTestLogsByPage" });

/**
 * @description: 更新测试用例配置
 */
export const updateTestCaseConfig = createCommand<{ caseId: string; config: nodeItem[] }, never>(testModuleId, {
  command: "UpdateTestCaseConfig"
});

/**
 * @description: 修改天波测试结果
 */
export const updateSkyDirectionAccuracyTestResult = createCommand<{ testResult: SkyTestResult }, never>(testModuleId, {
  command: "UpdateSkyDirectionAccuracyTestResult"
});

/**
 * @description: 修改地波发射源参数
 */
export const updateGeneratorInfo = createCommand<{ generator: GeneratorInfo }, never>(testModuleId, {
  command: "UpdateGeneratorInfo"
});

/**
 * @description: 获取地波数据
 * @return {*}
 */
export const getGroundDirectionAccuracies = createCommand<{ generatorId: string }, GroundDirectionAccuracies[]>(testModuleId, {
  command: "GetGroundDirectionAccuracies"
});

/**
 * @description: 修改地波数据
 */
export const updateGroundDirectionAccuracyTestResult = createCommand<{ testResult: GroundDirectionAccuracies }, never>(testModuleId, {
  command: "UpdateGroundDirectionAccuracyTestResult"
});

/**
 * @description: 获取环境参数
 */
export const getEnvironment = createCommand<{}, Environment>(testModuleId, { command: "GetEnvironment" });

export const getTestStatisticsInfo = createCommand<{}, TestStatus>(testModuleId, { command: "GetTestStatus" });

/**
 * @description: 对话框回调
 */
export const dialogCallback = createCommand<{ dialogInfo: DialogParams }, never>(testModuleId, { command: "DialogCallback" });
